#!/usr/bin/perl -w
#
#package DBFILLER;
#
#=head1 NAME
#
# Remote DB filler for shrodingerbox
#
#=head1 VERSION
#
# $Id: 
#
#=head1 SYNOPSIS
#
# db_filler.py -db MyData -s dbserver.com -u Usern$me -p Secr3tPass
#
#=head1 DESCRIPTION
#
# Script parses values from files in /home/pi/schrodingehome/pi/schroedinger/data/
# Script inserts values into database specified by its params
# Script ends after succesful insert. If insert failed, error message is displayed in error ouput stream
#
#=cut

use strict;
use warnings;
use LWP::Simple;
use POSIX;

my $temperature = `cat /home/pi/schroedinger/data/teplota.txt`;
my $water = `cat /home/pi/schroedinger/data/vlhkost.txt`;
my $lux = `cat /home/pi/schroedinger/data/svetlo.txt`;
my $date = strftime("%Y-%m-%d-%H:%M", localtime);
my $url = "http://shrodingerbox.4fan.cz/insert.php?teplota=" . $temperature . "&vlhkost=" . $water . "&svetlo=" . $lux . "&datum=" . $date;
print $url;
get($url);
